﻿using System;
using System.Collections.Generic;
using System.Linq;
using EXT;
using System.Data;

namespace BanHangCshap.Class.gkhtdl63.DAL
{
    public abstract class Phieuthu2DAL : clsBaseDAL
    {
        public DataTable Phieuthu2_Laydanhsach(DateTime Tungay, DateTime Denngay, bool Loai)
        {
            string xlSPName = "sp_Phieuthu2_Laydanhsach";
            string[] xlSPPara = { "@Tungay", "@Denngay", "@Loai" };
            object[] xlSPValu = { Tungay.ToDateTimeStart(), Denngay.ToDateTimeEnd(), Loai };
            return base.Select(xlSPName, xlSPPara, xlSPValu);
        }

        public DataTable Phieuthu2_Them(DAL.Entities.Phieuthu2 xlPT2)
        {
            string xlSPName = "sp_Phieuthu2_Them";
            string[] xlSPPara = { "@Ngay"
                                ,"@Ma"
                                ,"@NhanvienLap"
                                ,"@Id_Khachhang2"
                                ,"@Sotien"
                                ,"@Ghichu"
                                ,"@Loai"
                                 };
            object[] xlSPValu = { xlPT2.Ngay
                                ,xlPT2.Ma
                                ,xlPT2.NhanvienLap
                                ,xlPT2.Id_Khachhang2
                                ,xlPT2.Sotien
                                ,xlPT2.Ghichu
                                ,xlPT2.Loai
                                 };
            return base.InsertReturnObj(xlSPName, xlSPPara, xlSPValu);
        }

        public bool Phieuthu2_Capnhat(DAL.Entities.Phieuthu2 xlPT2)
        {
            string xlSPName = "sp_Phieuthu2_Capnhat";
            string[] xlSPPara = { "@Id",
                                    "@Ngay"
                                ,"@Ma"
                                ,"@NhanvienLap"
                                ,"@Id_Khachhang2"
                                ,"@Sotien"
                                ,"@Ghichu"
                                ,"@Loai"
                                 };
            object[] xlSPValu = { xlPT2.Id,xlPT2.Ngay
                                ,xlPT2.Ma
                                ,xlPT2.NhanvienLap
                                ,xlPT2.Id_Khachhang2
                                ,xlPT2.Sotien
                                ,xlPT2.Ghichu
                                ,xlPT2.Loai
                                 };
            return base.Update(xlSPName, xlSPPara, xlSPValu);
        }

        public DataTable Phieuthu2_Taomao(string xlPMa, bool xlLoai)
        {
            string xlSPName = "sp_Phieuthu2_Taomao";//sp_Phieuxuat2_Taoma
            string[] xlSPPara = { "@PMa", "@Loai" };
            object[] xlSPValu = { xlPMa, xlLoai };
            return base.Select(xlSPName, xlSPPara, xlSPValu);
        }

        public bool Phieuthu2_Xoa(long Id)
        {
            string xlSPName = "sp_Phieuthu2_Xoa";//sp_Phieuxuat2_Taoma
            string[] xlSPPara = { "@Id" };
            object[] xlSPValu = { Id };
            return base.Delete(xlSPName, xlSPPara, xlSPValu);
        }

        public DataTable Phieuthu2_In(long Id)
        {
            string xlSPName = "sp_Phieuthu2_In";//sp_Phieuxuat2_Taoma
            string[] xlSPPara = { "@Id" };
            object[] xlSPValu = { Id };
            return base.Select(xlSPName, xlSPPara, xlSPValu);
        }
        //Bệnh rồi bên kia có viết rồi 2 hàm này
        public DataTable Phieuthu2_TinhNocuKhachhang(object Ngay, long Id_Khachhang2)
        {
            string xlSPName = "sp_Khachang2_TinhnocuK";//sp_Phieuxuat2_Taoma
            DateTime x = (DateTime)Ngay;
            string[] xlSPPara = { "@Ngay", "@Id_Khachhang2" };
            object[] xlSPValu = { Ngay.ToDateTimeS(), Id_Khachhang2 };
            return base.Select(xlSPName, xlSPPara, xlSPValu);
        }

        public DataTable Phieuthu2_TinhNocuNCC(object Ngay, long Id_Khachhang2)
        {
            string xlSPName = "sp_Khachang2_TinhnocuN";//sp_Phieuxuat2_Taoma
            DateTime x = (DateTime)Ngay;
            string[] xlSPPara = { "@Ngay", "@Id_Khachhang2" };
            object[] xlSPValu = { Ngay.ToDateTimeS(), Id_Khachhang2 };
            return base.Select(xlSPName, xlSPPara, xlSPValu);
        }
    }
}
